<?php
namespace app\common\model;

class User extends Base
{
    protected $pk = 'id';

    //定义模型关联的表名
    protected $table = 'users';

    //自定义初始化
    protected static function init()
    {

    }

    public function getCreateTimeLabelAttr($value, $data)
    {
        if (empty($data['create_time'])) {
            return '未知';
        }
        return date('Y-m-d H:i:s', $data['create_time']);
    }

    public function getUpdateTimeLabelAttr($value, $data)
    {
        if (empty($data['update_time'])) {
            return '未知';
        }
        return date('Y-m-d H:i:s', $data['update_time']);
    }

    public function getLastLoginTimeLabelAttr($value, $data)
    {
        if (empty($data['last_login_time'])) {
            return '暂未登录';
        }
        return date('Y-m-d H:i:s', $data['last_login_time']);
    }

    public function getLastLoginIpLabelAttr($value, $data)
    {
        if (empty($data['last_login_ip'])) {
            return '';
        }
        return long2ip(intval($data['last_login_ip']));
    }
}